package com.sz.mes.excel.model;

import java.util.Date;
import java.lang.Double;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.HeadStyle;
import com.alibaba.excel.enums.poi.FillPatternTypeEnum;
import com.diboot.core.util.D;
import com.diboot.core.util.V;
import com.diboot.file.excel.BaseExcelModel;
import com.diboot.file.excel.annotation.ExcelBindDict;
import com.diboot.file.excel.annotation.ExcelBindField;
import com.diboot.file.excel.annotation.ExcelOption;
import com.fasterxml.jackson.annotation.JsonFormat;

import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;

import com.sz.mes.entity.ProductTask;

/**
 * 生产任务 导入model定义
 *
 * @author hem
 * @version 1.0
 * @date 2024-01-08
 * Copyright © szhs
 */
@Getter
@Setter
@ExcelIgnoreUnannotated
@HeadStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 1)
public class ProductTaskImportModel extends BaseExcelModel {

    /**
     * 单据编号
     */
    @Length(max = 100, message = "单据编号长度应小于100")
    @ExcelProperty(value = "单据编号")
    private String receiptNum;

    /**
     * 计划号
     */
    @Length(max = 100, message = "计划号长度应小于100")
    @ExcelProperty(value = "计划号")
    private String planNum;

    /**
     * 料品料号
     */
    @Length(max = 100, message = "料品料号长度应小于100")
    @ExcelProperty(value = "料品料号")
    private String productNum;
    /**
     * 料品名称
     */
    @Length(max = 255, message = "料品名称长度应小于255")
    @ExcelProperty(value = "料品名称")
    private String productName;
    /**
     * 料品规格
     */
    @Length(max = 100, message = "料品规格长度应小于100")
    @ExcelProperty(value = "料品规格")
    private String productSpecification;
    /**
     * 生产数量
     */
    @ExcelProperty(value = "生产数量")
    private Integer quantity;
    /**
     * 生产单位
     */
    @Length(max = 100, message = "生产单位长度应小于100")
    @ExcelProperty(value = "生产单位")
    private String productUnit;
    /**
     * 生产部门
     */
    @Length(max = 100, message = "生产部门长度应小于100")
    @ExcelProperty(value = "生产部门")
    private String productSection;
    /**
     * 计划开工日期
     */
    @DateTimeFormat(D.FORMAT_DATETIME_Y4MDHMS)
    @JsonFormat(pattern = D.FORMAT_DATETIME_Y4MDHMS)
    @ExcelProperty(value = "计划开工日期")
    private Date startTime;
    /**
     * 计划完工日期
     */
    @DateTimeFormat(D.FORMAT_DATETIME_Y4MDHMS)
    @JsonFormat(pattern = D.FORMAT_DATETIME_Y4MDHMS)
    @ExcelProperty(value = "计划完工日期")
    private Date endTime;
    /**
     * 入库数量
     */
    @Length(max = 100, message = "入库数量长度应小于100")
    @ExcelProperty(value = "入库数量")
    private String instockQuantity;
    /**
     * 备料料号
     */
    @Length(max = 100, message = "备料料号长度应小于100")
    @ExcelProperty(value = "备料料号")
    private String stockNum;
    /**
     * 备料名称
     */
    @Length(max = 100, message = "备料名称长度应小于100")
    @ExcelProperty(value = "备料名称")
    private String stockName;
    /**
     * 备料规格
     */
    @Length(max = 255, message = "备料规格长度应小于255")
    @ExcelProperty(value = "备料规格")
    private String stockSpecification;
    /**
     * 订单备料.料品.库存单位
     */
    @Length(max = 100, message = "订单备料.料品.库存单位长度应小于100")
    @ExcelProperty(value = "订单备料.料品.库存单位")
    private String unit;
    /**
     * 备料用量
     */
    @Length(max = 100, message = "备料用量长度应小于100")
    @ExcelProperty(value = "备料用量")
    private String stockDosage;
    /**
     * 备料发料日期
     */
    @Length(max = 100, message = "备料发料日期长度应小于100")
    @ExcelProperty(value = "备料发料日期")
    private String stockProvideTime;
    /**
     * 备料已发放数量
     */
    @Length(max = 100, message = "备料已发放数量长度应小于100")
    @ExcelProperty(value = "备料已发放数量")
    private String stockProvideQuantity;


    //    /**
//     * excel内容
//     */
//    @ExcelProperty(value = "excel内容")
//    private String excelData;
// 重写equals和hashCode方法，以便在过滤时能够正确地比较对象
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ProductTaskImportModel productTaskImportModel = (ProductTaskImportModel) o;
        Boolean taskNumSame = true;
        Boolean planNumSame = true;
        Boolean receiptNumSame = true;
        Boolean productNumSame = true;
        Boolean productNameSame = true;
        Boolean productSpecificationSame = true;
        Boolean quantitySame = true;
        Boolean productUnitSame = true;
        Boolean productSectionSame = true;
        Boolean startTimeSame = true;
        Boolean endTimeSame = true;
        Boolean instockQuantitySame = true;
        Boolean stockNumSame = true;
        Boolean stockNameSame = true;
        Boolean stockSpecificationSame = true;
        Boolean unitSame = true;
        Boolean stockDosageSame = true;
        Boolean stockProvideTimeSame = true;
        Boolean stockProvideQuantitySame = true;
        Boolean productTaskCreateTimeSame = true;


        if (planNum != null) {
            planNumSame = planNum.equals(productTaskImportModel.planNum);
        }
        if (receiptNum != null) {
            receiptNumSame = receiptNum.equals(productTaskImportModel.receiptNum);
        }
        if (productNum != null) {
            productNumSame = productNum.equals(productTaskImportModel.productNum);
        }
        if (productName != null) {
            productNameSame = productName.equals(productTaskImportModel.productName);
        }
        if (productSpecification != null) {
            productSpecificationSame = productSpecification.equals(productTaskImportModel.productSpecification);
        }
        if (quantity != null) {
            quantitySame = quantity.equals(productTaskImportModel.quantity);
        }
        if (productUnit != null) {
            productUnitSame = productUnit.equals(productTaskImportModel.productUnit);
        }
        if (productSection != null) {
            productSectionSame = productSection.equals(productTaskImportModel.productSection);
        }
        if (startTime != null) {
            startTimeSame = startTime.equals(productTaskImportModel.startTime);
        }
        if (endTime != null) {
            endTimeSame = endTime.equals(productTaskImportModel.endTime);
        }
        if (instockQuantity != null) {
            instockQuantitySame = instockQuantity.equals(productTaskImportModel.instockQuantity);
        }
        if (stockNum != null) {
            stockNumSame = stockNum.equals(productTaskImportModel.stockNum);
        }
        if (stockName != null) {
            stockNameSame = stockName.equals(productTaskImportModel.stockName);
        }
        if (stockSpecification != null) {
            stockSpecificationSame = stockSpecification.equals(productTaskImportModel.stockSpecification);
        }
        if (unit != null) {
            unitSame = unit.equals(productTaskImportModel.unit);
        }
        if (stockDosage != null) {
            stockDosageSame = stockDosage.equals(productTaskImportModel.stockDosage);
        }
        if (stockProvideTime != null) {
            stockProvideTimeSame = stockProvideTime.equals(productTaskImportModel.stockProvideTime);
        }
        if (stockProvideQuantity != null) {
            stockProvideQuantitySame = stockProvideQuantity.equals(productTaskImportModel.stockProvideQuantity);
        }


        return planNumSame && receiptNumSame && productNumSame && productNameSame && productSpecificationSame &&
                quantitySame && productUnitSame && productSectionSame && startTimeSame && endTimeSame && instockQuantitySame &&
                stockNumSame && stockNameSame && stockSpecificationSame && unitSame && stockDosageSame && stockProvideTimeSame &&
                stockProvideQuantitySame;
    }


    @Override
    public int hashCode() {
        return Objects.hash(planNum, receiptNum, productNum, productName, productSpecification, quantity,
                productUnit, productSection, startTime, endTime, instockQuantity, stockNum, stockName, stockSpecification,
                unit, stockDosage, stockProvideTime, stockProvideQuantity);
    }
}
